package edu.hawaii.myisern.action;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;

/**
 * Straightforward logout action that logs the user out and then sends to an exit page.
 * 
 * This class is modified from the bugzooky example.
 * 
 * @author Tim Fennell
 */
public class LogoutActionBean implements ActionBean {

  /** Required by the ActionBean interface. */
  private ActionBeanContext context;

  /**
   * The logout function.
   * @return the redirected page
   * @throws Exception any exceptions.
   */
  public Resolution logout() throws Exception {
    getContext().getRequest().getSession().invalidate();
    return new RedirectResolution("/logout.jsp");
  }

  /**
   * Gets the context. Required by the interface.
   * 
   * @return The context.
   */
  public ActionBeanContext getContext() {
    return context;
  }

  /**
   * Sets the context. Required by the interface.
   * 
   * @param context The context to set.
   */
  public void setContext(ActionBeanContext context) {
    this.context = context;
  }
}
